package com.wn.inventory.web;

import com.wn.common.PageBean;
import com.wn.common.ResponseEntity;
import com.wn.entity.PurchaseInWarehouseApplication;
import com.wn.inventory.service.PurchaseInWarehouseApplicationService;
import com.wn.inventory.vo.PurchaseInWarehouseApplicationVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @ author     ：NST
 * @ date       ：Created in 2022/10/21 9:41
 * @ description：
 * @ modified By：采购入库申请表Controller
 * @ version:
 */
@RestController
@RequestMapping("inventory/purchase")
public class PurchaseInWarehouseApplicationController {
    @Autowired
    PurchaseInWarehouseApplicationService purchaseInWarehouseApplicationService;

    /**
     * @param purchase
     * @return com.wn.common.ResponseEntity
     * @ author nst
     * @ date 2022/10/21 9:44
     * @ Description 增加采购入库信息
     * 需传入 申请人id,采购编号,批次号,采购明细集合,流程id(测试，后续由流程模块获取)
     */
    @RequestMapping("add")
    public ResponseEntity add(@RequestBody @Validated PurchaseInWarehouseApplication purchase, HttpServletRequest request) {
        purchaseInWarehouseApplicationService.add(purchase,request);
        return ResponseEntity.success;
    }

    @RequestMapping("addition")
    public ResponseEntity getBycondition(@RequestBody PurchaseInWarehouseApplicationVo purchase) {
        PageBean<PurchaseInWarehouseApplication> pageBean = purchaseInWarehouseApplicationService.getByCondition(purchase);
        return new ResponseEntity(pageBean);
    }

}
